package com.mm.learn.login;/**
 * @author wdx
 * @create 2021-09-23 16:05
 */

/**
 * @author wdx
 * @date 2021年09月23日 16:05
 */
public class User implements Cloneable {

    public User(String username, String nickname) {
        this.username = username;
        this.nickname = nickname;
    }

    private String username;
    private String nickname;
    private Subject subject;

    public Subject getSubject() {
        return subject;
    }

    public void setSubject(Subject subject) {
        this.subject = subject;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }


    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", nickname='" + nickname + '\'' +
                ", subject=" + subject +
                '}';
    }

    public static void main(String[] args) throws CloneNotSupportedException {
        User user = new User("sss","ddd");
        Subject subject1 = new Subject("数学");
        user.setSubject(subject1);
//        Subject subject2 = (Subject) subject1.clone();
        User clone = (User) user.clone();
        user.getSubject().setKm("ssssss");
        System.out.println(user.getSubject().hashCode());
        System.out.println(clone.getSubject().hashCode());
        System.out.println(user == clone);
    }
}
